package com.fjxd.planeTicket.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fjxd.planeTicket.pojo.Ticket;
import com.fjxd.planeTicket.vo.TicketVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author csw
 */
@Mapper
public interface PlaneTicketMapper extends BaseMapper<Ticket> {

    /**
     * 获取机票
     *
     * @param fId 航班号id
     * @return 机票信息
     */
    @Select("select * from tb_ticket where f_id = #{fId}")
    List<Ticket> getTicketFlightNumberId(Integer fId);

    /**
     * 获取机票
     *
     * @param fId       航班号id
     * @param startDate 起飞日期
     * @return 机票信息
     */
    @Select("select * from tb_ticket where f_id = #{fId} and start_date = #{startDate} limit 1 ")
    Ticket getTicketByFlightNumberId(Integer fId, String startDate);
    @Select("select *from tb_ticket where f_id=#{fid} and start_date>utc_date() ORDER BY RAND() limit 1;")
    Ticket getPlaneByFid(Integer fid);
}
